package com.protocols;

import java.io.Serializable;
import java.nio.ByteBuffer;

public class OctaveInteger implements Serializable{
	public int Value;
	private int Length;
	
	public OctaveInteger() {
		Value = 0;
		Length = 0;
	}

	public OctaveInteger(int length) {
		Value = 0;
		Length = length;
	}
	
	public OctaveInteger(int val,int length) {
		Value = val;
		Length = length;
	}

	public int getValue() {
		return Value;
	}
	public void setValue(int value) {
		Value = value;
	}
	public int getLength() {
		return Length;
	}
	public void setLength(int length) {
		Length = length;
	}
	public byte [] getByteArray(){
		if (Length==6)
			return new byte[] {(byte)(Value >>> 40),(byte)(Value >>> 32),(byte) (Value >>> 24),(byte)(Value >>> 16),(byte)(Value >>> 8),(byte)Value};
		if (Length==5)
			return new byte[] {(byte)(Value >>> 32),(byte) (Value >>> 24),(byte)(Value >>> 16),(byte)(Value >>> 8),(byte)Value};
		if (Length==4)
				return new byte[] {(byte)(Value >>> 24),(byte)(Value >>> 16),(byte)(Value >>> 8),(byte)Value};
		if (Length==3)
			return new byte[] {(byte)(Value >>> 16),(byte)(Value >>> 8),(byte)Value};
		if (Length==2)
			return new byte[] {(byte)(Value >>> 8),(byte)Value};
		if (Length==1)
			return new byte[] {(byte)Value};
		
		return  new byte[0];

		
		
	}
	

}
